﻿using CuaHangLego.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using CuaHangLego.DataAccess;

namespace CuaHangLego.Bussiness.Parser
{
    public class SanPhamParser
    {
        public static SanPham Parse(SqlDataReader sdata)
        {
            SanPham sp = new SanPham();
            sp.MaSo = int.Parse(sdata["ID"].ToString());
            sp.Ten = sdata["Ten"].ToString();
            sp.ChuDe = ChuDeDA.Instance.GetByID(int.Parse(sdata["ChuDeID"].ToString()));
            sp.GiaBan = int.Parse(sdata["GiaBan"].ToString());
            sp.SoManhGhep = int.Parse(sdata["SoManhGhep"].ToString());
            sp.BaoHanh = int.Parse(sdata["BaoHanh"].ToString());
            sp.NgaySX = DateTime.Parse(sdata["NgaySX"].ToString());
            sp.HinhAnh = sdata["HinhAnh"].ToString();
            sp.StateType = SanPham.StateTypes.NoChange;
            return sp;
        }
    }
}
